package com.hwl.demo5.factory;

import com.hwl.demo1.service.Operation;
import com.hwl.demo1.service.impl.Add;
import com.hwl.demo1.service.impl.Div;
import com.hwl.demo1.service.impl.Mul;
import com.hwl.demo1.service.impl.Sub;
import com.hwl.demo5.service.IFactory;

/**
 * 基础运算工厂
 *
 * @author sentry
 * @since 2023-03-18
 */
public class FactoryBasic implements IFactory {

    @Override
    public Operation createOperation(String operType) {
        switch (operType) {
            case "+":
                return new Add();
            case "-":
                return new Sub();
            case "*":
                return new Mul();
            case "/":
                return new Div();
            default:
                throw new RuntimeException("暂不支持该操作符");
        }
    }
}
